import { userInfo, userMenus } from '@/mockData/user'
// import request from '../index'
import type { IAccount, ILoginInfo, IMenuList, IUserInfo } from '@/types'

/**
 * 用户登录
 * @param data 登录参数
 */
export const accountLogin = (data: IAccount): Promise<ILoginInfo> => {
  //   request.post({
  //     url: '/login',
  //     data
  //   })
  console.log('用户登录', data)
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        user_id: 1,
        token: '123456789',
        role_id: 1
      })
    }, 200)
  })
}

/**
 * 获取用户信息
 * @param id 用户id
 */
export const getUserInfoById = (id: string): Promise<IUserInfo> => {
  console.log('获取用户信息', id)
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(userInfo)
    }, 200)
  })
}

/**
 * 获取菜单信息
 * @param id 角色id
 */
export const getUserMenusByRoleId = (id: Number): Promise<IMenuList> => {
  console.log('获取菜单信息', id)
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(userMenus)
    }, 200)
  })
}
